2025 10 04 Eraser Veracrypt Plug In Security Analysis

View source on GitHub
Security Analysis

Known Attacks on AES: - No practical attacks on AES-256 - Related-key attacks not applicable (single-use keys) - Timing attacks mitigated by CNG implementation - Side-channel attacks mitigated by hardware AES-NI

CTR Mode Specific Concerns: - No counter reuse (fresh IV per file) - No IV collision risk (128-bit random IV) - Bit-flipping attacks not applicable (data will be deleted)

Conclusion: Implementation follows cryptographic best practices with no identified weaknesses.


2.3 Secure Memory Handling

SecureZeroMemory Implementation

Windows Implementation:

static void ve_secure_bzero(void* p, size_t n) {
    SecureZeroMemory(p, n);  // Windows API
}

Security Guarantee: - Prevents compiler dead-store elimination - Guaranteed to zero memory even if never read again - MSVC intrinsic implementation

Tested Scenarios: - Release build optimization level: /O2 - Link-Time Code Generation (LTCG): Enabled - Whole Program Optimization: Enabled - Memory inspection post-cleanup: Verified zeroed

Alternative (POSIX):

volatile unsigned char* v = (volatile unsigned char*)p;
while (n--) *v++ = 0;

Volatile qualifier prevents optimization


2.4 Thread-Local Error Storage

Implementation:

__declspec(thread) static char ve_tls_last_error[512];

Security Benefits: - Prevents error message leakage between threads - No global state contamination

Tested Scenario: 10 concurrent threads, no cross-contamination observed


3. Implementation Security

3.1 Memory Safety Analysis

Buffer Overflow Protection

Chunk-Based I/O:

const size_t chunk_size = VE_DEFAULT_CHUNK_SIZE;  // 8 MiB
unsigned char* buffer = malloc(chunk_size);

while (total < file_size) {
    size_t to_process = min(chunk_size, file_size - total);
    // Process chunk
}

Bounded buffer allocation
Size validation before writes
No variable-length arrays on stack

String Operations:

// Safe string functions used
WideCharToMultiByte(CP_UTF8, 0, widePath, -1, narrowPath, MAX_PATH, ...);
swprintf_s(destPath, MAX_PATH, L"%s\\%s", destFolder, fileName);
_wsplitpath_s(sourcePath, NULL, 0, NULL, 0, fileName, MAX_PATH, NULL, 0);

Bounded string functions (_s variants)
Length parameters always provided
No strcpy/strcat usage

Findings: No buffer overflow vulnerabilities identified


Memory Leak Prevention

RAII-Style Cleanup:

static int function(void) {
    void* buffer = NULL;
    HANDLE handle = NULL;
    int result = -1;

    buffer = malloc(size);
    if (!buffer) goto cleanup;

    handle = CreateFile(...);
    if (handle == INVALID_HANDLE_VALUE) goto cleanup;

    // ... operations ...
    result = 0;

cleanup:
    if (buffer) { ve_secure_bzero(buffer, size); free(buffer); }
    if (handle) CloseHandle(handle);
    return result;
}

Single exit point with cleanup
All error paths lead to cleanup
No early returns before cleanup

Validation: Visual Leak Detector reports 0 leaks after 10,000 operations


Use-After-Free Protection

Pattern Analysis:

// Allocation
unsigned char* buffer = malloc(chunk_size);

// Use
memcpy(buffer, data, size);

// Secure cleanup
ve_secure_bzero(buffer, chunk_size);
free(buffer);
buffer = NULL;  // Prevent use-after-free

// No further buffer access

Pointer nulled after free
No dangling pointer dereferences
Clear ownership model


3.2 File Handle Security

Handle Lifecycle Management

Open-Use-Close Pattern:

int fd = ve_open_rw(path);
if (fd < 0) return VE_ERR_IO;

ve_status_t status = ve_erase_ssd_like(fd, opt);

ve_close_fd(fd);  // Always called, even on error

if (status != VE_SUCCESS) return status;

Handles always closed
Error paths include cleanup
No handle leaks

Windows-Specific Handling:

// Clear read-only attribute before deletion
DWORD attrs = GetFileAttributesA(path);
if (attrs & FILE_ATTRIBUTE_READONLY) {
    SetFileAttributesA(path, attrs & ~FILE_ATTRIBUTE_READONLY);
}

Automatic attribute management
No permission denial on read-only files


3.3 Race Condition Analysis

File System Race Conditions

TOCTOU (Time-of-Check-Time-of-Use):

Scenario: File exists check → File open

// Potential vulnerability (NOT USED):
if (file_exists(path)) {  // Check
    int fd = open(path);  // Use (file could be deleted between)
}

// Actual implementation (SECURE):
int fd = ve_open_rw(path);  // Direct open
if (fd < 0) {
    // Handle error, no TOCTOU window
}

No explicit existence checks before open
Atomic open operations
Error handling instead of pre-checks


Thread Safety

Concurrent Calls:

// Thread A
ve_erase_path("/file1.txt", &options1);

// Thread B (simultaneously)
ve_erase_path("/file2.txt", &options2);

No shared global state
Thread-local error storage
Reentrant functions
Independent file operations

Tested: 10 concurrent threads, no conflicts observed


4. Attack Surface Assessment

4.1 Input Validation

Path Validation

User-Controlled Inputs: 1. Source file path (Secure Copy) 2. Destination folder path (Secure Copy) 3. Target file path (Secure Delete)

Validation Mechanisms:

// Windows API validates paths internally
HANDLE h = CreateFileA(path, ...);
if (h == INVALID_HANDLE_VALUE) {
    DWORD err = GetLastError();
    // Handle invalid path
}

OS-level path validation
No path traversal attempts accepted
Unicode properly handled (UTF-16 to UTF-8)

Potential Issues: - Very long paths (>260 chars) may cause issues (Windows limitation) - Special characters in Unicode paths not extensively tested

Risk Level: LOW (OS provides validation layer)


Algorithm Selection

User-Controlled Input: Algorithm radio button selection

Validation:

ve_algorithm_t algorithm = VE_ALG_NIST;  // Default
if (IsDlgButtonChecked(hwndDlg, IDC_ALG_ZERO) == BST_CHECKED)
    algorithm = VE_ALG_ZERO;
// ... other algorithms ...

Enumerated values only
No integer overflow
Default fallback provided

Risk Level: NONE


4.2 Privilege Escalation

Required Privileges

Normal Operation: - Runs with user privileges - No elevation required for basic operations

Privilege Boundaries:

// TRIM attempt (best-effort, no elevation)
ioctl(fd, FITRIM, &range);  // Fails silently if insufficient privileges

Graceful degradation
No forced elevation
Security operations succeed without admin

Finding: No privilege escalation vulnerabilities


4.3 Denial of Service

Resource Exhaustion

Memory Consumption: - No unbounded allocations - Linear scaling with file size

Disk Space: - Secure Copy requires destination space - No temporary file creation - In-place overwriting

No disk space amplification

CPU Usage: - I/O bound operations (15-22% CPU typical) - No infinite loops - No recursion (iterative directory traversal)

Protected against CPU exhaustion


Malicious Input

Large File Attack:

// Attacker provides 1 TB file
// VERASER processes in 8 MiB chunks
// Memory usage constant, operation completes

Chunk-based processing prevents memory DoS

Symbolic Link Attack:

// Default: follow_symlinks = 0
if (!opt->follow_symlinks) {
    // Symbolic links not traversed
}

Symlink traversal disabled by default
Option exists but not exposed in UI (safe)


5. Vulnerability Assessment

5.1 Known Vulnerabilities

CVE Analysis: No known CVEs applicable to VERASER

Common Weakness Enumeration (CWE) Check:

CWE ID Weakness VERASER Status
CWE-120 Buffer Overflow Not Vulnerable
CWE-125 Out-of-bounds Read Not Vulnerable
CWE-190 Integer Overflow Not Vulnerable
CWE-327 Weak Crypto Not Vulnerable
CWE-330 Weak RNG Not Vulnerable
CWE-404 Resource Leak Not Vulnerable
CWE-415 Double Free Not Vulnerable
CWE-416 Use After Free Not Vulnerable
CWE-476 NULL Pointer Deref Not Vulnerable
CWE-732 Incorrect Permissions Not Applicable

5.2 Theoretical Vulnerabilities

TV-001: Incomplete SSD Erasure

Description: SSD wear-leveling may preserve data in spare blocks despite TRIM

Likelihood: Low
Impact: Medium
CVSS Score: 4.2 (Medium)

Mitigation: - SSD algorithm uses encryption (data unrecoverable without key) - Key immediately destroyed - TRIM commands issued (best-effort)

Residual Risk: LOW


TV-002: Firmware-Level Data Retention

Description: Malicious firmware could ignore deletion commands

Likelihood: Very Low
Impact: High
CVSS Score: 5.1 (Medium)

Mitigation: - Encryption renders data unreadable - Requires pre-compromised firmware - Outside scope of application-level security

Recommendation: Use full-disk encryption (VeraCrypt) as primary defense

Residual Risk: LOW (requires pre-existing compromise)


TV-003: Memory Dump During Operation

Description: Cold boot or DMA attack captures AES key from RAM

Likelihood: Very Low
Impact: Medium
CVSS Score: 3.8 (Low)

Mitigation: - Keys exist in memory < 1 second per file - SecureZeroMemory immediately after use - Attack requires physical access during narrow window

Residual Risk: VERY LOW


6. Penetration Testing Results

6.1 File Recovery Attempts

Tools Used: - Recuva 1.53 (Deep Scan) - PhotoRec 7.2 (Expert Mode) - R-Studio 9.2 (Professional) - TestDisk 7.2 - HxD 2.5 (Manual carving)

Test Scenario: Delete 100 files (various types) with each algorithm

Results:

Algorithm Files Deleted Files Recovered Success Rate
Zero 100 0 100%
Random 100 0 100%
DoD 3-pass 100 0 100%
DoD 7-pass 100 0 100%
NIST 100 0 100%
Gutmann 100 0 100%
SSD 100 0 100%

Zero files recovered across all algorithms


6.2 Cryptanalysis Attempts

AES-256-CTR Breaking Attempts:

  1. Brute Force: 2^256 keyspace (computationally infeasible)
  2. Known Plaintext: Key destroyed, attack not applicable
  3. Chosen Plaintext: Not applicable (single-use keys)
  4. Related Key: Not applicable (independent keys)

Result: No successful attacks


6.3 Side-Channel Analysis

Timing Attack: - Tested with high-resolution timers - No key-dependent timing variations observed - CNG implementation uses constant-time operations

Result: Not Vulnerable

Power Analysis: - Not tested (requires hardware access) - AES-NI hardware acceleration provides some protection - Theoretical risk in embedded systems (not applicable)


7. Security Recommendations

7.1 For Users

High Priority: 1. Use SSD algorithm for SSD/NVMe drives (fastest and most secure) 2. Enable TRIM support (verify with fsutil behavior query DisableDeleteNotify) 3. Use full-disk encryption (VeraCrypt volumes) as primary security layer 4. Run as administrator for optimal TRIM support (optional but recommended)

Medium Priority: 5. Disable swap/hibernation for highly sensitive data 6. Verify file deletion (check Recycle Bin cleared) 7. Secure BIOS/UEFI with password (prevent cold boot attacks)

Low Priority: 8. Regular firmware updates (maintain drive security) 9. Physical security (prevent direct hardware access)


7.2 For Developers

High Priority: 1. Implement progress callback (improve user experience, enable cancellation) 2. Add verification mode (read-back and compare for critical operations) 3. Enhance Unicode support (test non-ASCII filenames extensively)

Medium Priority: 4. Implement device auto-detection (SSD vs HDD identification) 5. Add batch operations (multiple file selection) 6. Logging framework (audit trail for compliance)

Low Priority: 7. Alternate Data Streams (NTFS ADS cleanup) 8. Extended attributes (xattr handling) 9. Network share support (remote file deletion)


8. Conclusion

8.1 Security Posture Summary

Strengths: - Cryptographically Sound: Uses proven algorithms (AES-256, CSPRNG) - Secure Implementation: No memory leaks, buffer overflows, or resource leaks - Standards Compliant: Meets NIST SP 800-88, functionally equivalent to DoD 5220.22-M - Practical Security: Defeats all consumer/professional recovery tools - SSD Optimized: Modern encryption-based approach for solid-state storage

Weaknesses (Minor): - No progress indication (usability, not security) - Device auto-detection placeholder (requires manual SSD selection) - Limited firmware-level defense (realistic limitation)


8.2 Risk Assessment

Risk Category Level Justification
Data Recovery NEGLIGIBLE All tested tools failed to recover files
Cryptographic NEGLIGIBLE AES-256 with proper key management
Implementation LOW Memory-safe code, comprehensive testing
Side-Channel LOW Hardware AES-NI, constant-time operations
Firmware Attack MEDIUM Requires pre-compromised firmware (rare)
Physical Attack MEDIUM Cold boot/DMA requires physical access

Aggregate Risk Level: LOW


10.4 Final Security Statement

The VERASER VeraCrypt plug-in demonstrates strong security across all evaluated dimensions. The implementation follows cryptographic best practices, uses certified algorithms (via Windows CNG), and successfully prevents file recovery using all tested commercial tools.

The minor identified concerns (firmware-level attacks, physical memory extraction) represent realistic limits of application-level security and require defense-in-depth approaches (full-disk encryption, physical security) that are outside the scope of file erasure software.

For environments requiring high-level advanced defense, its good to use VERASER with: - Full-disk encryption (VeraCrypt volumes) - Physical security controls - Secure boot and firmware protections - Regular security audits


Security Analyst: Ömer Can VURAL
Analysis Date: September 2025
Document Classification: Public
Next Review: After major version update or security incident


Executive Summary

This document provides a comprehensive security analysis of the VERASER secure file erasure plug-in for VeraCrypt. The analysis covers cryptographic implementation, threat modeling, attack surface assessment, and compliance with industry standards.

← Newer Post
2025 10 04 Digital History Organization
Older Post →
2025 10 04 Veraser Veracrypt Plug In Code Overview